package com.example.shixunandjavagotoyangchen.BoosYang.Day003;

import android.util.Log;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;

import com.example.modelviewpresenter.View.BasterFragment;
import com.example.shixunandjavagotoyangchen.BoosYang.Day003.Day003_FX2.NAALC;
import com.example.shixunandjavagotoyangchen.BoosYang.Day003.Day003_FX2.NAALCadpter;
import com.example.shixunandjavagotoyangchen.BoosYang.Day003.Day003_FX3.XingdongAdpter1;
import com.example.shixunandjavagotoyangchen.BoosYang.Day003.Day003_FX3.XingdongAdpter2;
import com.example.shixunandjavagotoyangchen.BoosYang.Day003.Day003_FX3.XingdongBean;
import com.example.shixunandjavagotoyangchen.R;
import com.google.gson.Gson;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Response;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.listener.OnRefreshLoadMoreListener;

import java.util.List;

public class BlankFragmentDay003_FX3 extends BasterFragment implements OnRefreshLoadMoreListener {

    private SmartRefreshLayout DongSmartRefreshLayout;
    private RecyclerView DongRecyclerView1;
    private RecyclerView DongRecyclerView2;
    public boolean isqje=true;

    @Override
    public int BandLayout() {
        return R.layout.fragment_blank_fragment_day003__fx3;
    }

    @Override
    public void initView() {

        DongSmartRefreshLayout = (SmartRefreshLayout) findViewById(R.id.Dong_SmartRefreshLayout);
        DongRecyclerView1 = (RecyclerView) findViewById(R.id.Dong_RecyclerView1);
        DongRecyclerView2 = (RecyclerView) findViewById(R.id.Dong_RecyclerView2);
        DongSmartRefreshLayout.setOnRefreshLoadMoreListener(this);
        DongRecyclerView1.setLayoutManager(new StaggeredGridLayoutManager(1,StaggeredGridLayoutManager.HORIZONTAL));
        DongRecyclerView2.setLayoutManager(new StaggeredGridLayoutManager(2,StaggeredGridLayoutManager.VERTICAL));


    }

    @Override
    public void initDate() {


        OkGo.<String>get("http://82.156.173.100:8087//video/findVideos?currentPage=66&pageSize=10").execute(new StringCallback() {
            @Override
            public void onSuccess(Response<String> response) {
                Gson gson = new Gson();
                XingdongBean xingdongBean = gson.fromJson(response.body().toString(), XingdongBean.class);
                List<XingdongBean.DataBean> shequBeans = xingdongBean.getData();
                XingdongAdpter1 aadpter = new XingdongAdpter1(shequBeans);
                DongRecyclerView1.setAdapter(aadpter);
            }
        });




        OkGo.<String>get("http://82.156.173.100:8087//video/findVideos?currentPage=66&pageSize=10").execute(new StringCallback() {
            @Override
            public void onSuccess(Response<String> response) {
                Gson gson = new Gson();
                XingdongBean xingdongBean = gson.fromJson(response.body().toString(), XingdongBean.class);
                List<XingdongBean.DataBean> shequBeans = xingdongBean.getData();
                XingdongAdpter2 aadpter = new XingdongAdpter2(shequBeans);
                DongRecyclerView2.setAdapter(aadpter);
            }
        });


    }

    @Override
    public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
        isqje =false;
        refreshLayout.finishLoadMore();
        refreshLayout.finishRefresh();
    }

    @Override
    public void onRefresh(@NonNull RefreshLayout refreshLayout) {

        if (isqje){
            Log.i("aaa","la1");
        }
        refreshLayout.finishLoadMore();
        refreshLayout.finishRefresh();

    }


}
